var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/work-flow/service.ts
var service_exports = {};
__export(service_exports, {
  RollBack: () => RollBack,
  addSubTaskAsync: () => addSubTaskAsync,
  carbonCopy: () => carbonCopy,
  checkPreCompleteTask: () => checkPreCompleteTask,
  checkPreRollback: () => checkPreRollback,
  checkPreStartProcessInstance: () => checkPreStartProcessInstance,
  compeleteTask: () => compeleteTask,
  createOrUpdateContent: () => createOrUpdateContent,
  deleteContentById: () => deleteContentById,
  getCommonWordHelp: () => getCommonWordHelp,
  getCompletedNodeInfo: () => getCompletedNodeInfo,
  getNextUserTaskNodes: () => getNextUserTaskNodes,
  getProcessInitialActivity: () => getProcessInitialActivity,
  getRollBackInfo: () => getRollBackInfo,
  getSignatureByUser: () => getSignatureByUser,
  getSignatureListByCurrentUser: () => getSignatureListByCurrentUser,
  getToDoInfo: () => getToDoInfo,
  getUnHandledNodeInfo: () => getUnHandledNodeInfo,
  getWorkFlowHis: () => getWorkFlowHis,
  getWorkFlowInfo: () => getWorkFlowInfo,
  saveRemarkPanelWidth: () => saveRemarkPanelWidth,
  updateNotificationReadFlg: () => updateNotificationReadFlg,
  validSignatureInfoByPassword: () => validSignatureInfoByPassword
});
module.exports = __toCommonJS(service_exports);
var import_util = require("../../util");
var import_util2 = require("./util");
async function getWorkFlowInfo({ wfPiId, wfTaskId, wfOType, copyId, nodeDefKey }) {
  const taskDefKey = copyId ? nodeDefKey : "";
  const { code, message, data } = await import_util.iup.request.body({
    url: "workflow/task/getTaskExecutionInfo",
    data: { procInstId: wfPiId, taskId: wfTaskId, wfotype: wfOType, taskDefKey }
  });
  if (code === 0) {
    return data || {};
  } else {
    await (0, import_util2.wfAlert)(import_util2.NGLang.alertTitle, message || import_util2.NGLang.paramError);
  }
}
async function getWorkFlowHis({ procInstId }) {
  const { code, message, data } = await import_util.iup.request.body({
    url: "workflow/process/getProcessComments",
    data: { procInstId }
  });
  if (code === 0) {
    return data || [];
  } else {
    await (0, import_util2.wfAlert)(import_util2.NGLang.getFlowHisError, message);
    return [];
  }
}
async function getCommonWordHelp() {
  const resp = await import_util.iup.request.get({
    url: "workflow/content/getCommonContents"
  });
  if ((resp == null ? void 0 : resp.code) === 0) {
    return resp.data;
  } else {
    return [];
  }
}
async function createOrUpdateContent(content, id) {
  const resp = await import_util.iup.request.body({
    url: "workflow/content/createOrUpdateContent",
    data: {
      content,
      id
    }
  });
  if ((resp == null ? void 0 : resp.code) === 0) {
    return resp;
  } else {
    await (0, import_util2.wfAlert)(import_util2.NGLang.alertTitle, import_util2.NGLang.paramError);
    return resp;
  }
}
async function deleteContentById(contentIds) {
  const resp = await import_util.iup.request.body({
    url: "workflow/content/deleteContentById",
    data: {
      contentIds
    }
  });
  if ((resp == null ? void 0 : resp.code) === 0) {
    return true;
  } else {
    await (0, import_util2.wfAlert)(import_util2.NGLang.alertTitle, resp == null ? void 0 : resp.message);
    return false;
  }
}
async function getSignatureListByCurrentUser() {
  const resp = await import_util.iup.request.get({
    url: "WM/Archive/WmIoSignature/GetSignatureListByCurrentUser"
  });
  if (resp.Record && resp.Record.length) {
    return resp.Record.map((d) => {
      return {
        value: d.PhId,
        label: d.Cname,
        origin: {
          ...d,
          MarkPath: d.MarkPath ? import_util.iup.getHttpUrl(d.MarkPath) : ""
        }
      };
    });
  }
  return [];
}
async function validSignatureInfoByPassword({ PhId, pwd }) {
  const resp = await import_util.iup.request.get({
    url: "WM/Archive/WmIoSignature/GetSignatureInfogByPassword",
    data: {
      id: PhId,
      password: pwd
    }
  });
  return !!(resp.Record && resp.Record.length);
}
function updateNotificationReadFlg({ piId }) {
  import_util.iup.request.get({
    url: "WorkFlow3/ProcessNotification/UpdateNotificationReadFlg",
    data: { piid: piId }
  }).then();
}
function saveRemarkPanelWidth(width) {
  if (width <= 0) {
    return;
  }
}
async function getProcessInitialActivity(processDefinitionId) {
  const resp = await import_util.iup.request.get({
    data: { processDefinitionId },
    url: "workflow/processDefinition/getProcessInitialActivity"
  });
  if (resp.code === 0) {
    return resp.data;
  } else {
    return {};
  }
}
async function checkPreStartProcessInstance(params) {
  let resp = await import_util.iup.request.body({
    data: { ...params },
    url: "workflow/process/checkPreStartProcessInstance"
  });
  return resp;
}
async function checkPreRollback(taskId) {
  let resp = await import_util.iup.request.get({
    data: { taskId },
    url: "workflow/task/checkPreRollback"
  });
  return resp;
}
async function getRollBackInfo(taskId) {
  const resp = await import_util.iup.request.get({
    url: "workflow/task/getRollbackExecutionInfo",
    data: { taskId }
  });
  if (resp.code === 0) {
    return resp.data;
  }
}
async function RollBack(params) {
  const resp = await import_util.iup.request.body({
    url: "workflow/task/rollback",
    data: { ...params }
  });
  if (resp.code) {
    return resp;
  } else {
    return resp;
  }
}
async function addSubTaskAsync(params) {
  const resp = await import_util.iup.request.body({
    url: "workflow/task/addSubTasks",
    data: { ...params }
  });
  return resp;
}
async function checkPreCompleteTask(taskId) {
  let resp = await import_util.iup.request.get({
    data: { taskId },
    url: `workflow/task/checkPreCompleteTask?taskId=${taskId}`
  });
  return resp;
}
async function compeleteTask(params) {
  const resp = await import_util.iup.request.body({
    url: "workflow/task/completeTask",
    data: { ...params }
  });
  return resp;
}
async function carbonCopy(taskId, userNos, appCode = "0100") {
  const resp = await import_util.iup.request.body({
    url: "/workflow/copy/carbonCopy",
    data: {
      userNos,
      taskId,
      appCode
    }
  });
  return resp;
}
async function getToDoInfo(taskId) {
  const resp = await import_util.iup.request.get({
    url: `workflow/task/getToDoInfo?taskId=${taskId}`
  });
  if (resp.code === 0) {
    return resp.data;
  } else {
    await (0, import_util2.wfAlert)(import_util2.NGLang.getFlowHisError, resp.message);
    return null;
  }
}
async function getCompletedNodeInfo(params) {
  const resp = await import_util.iup.request.get({
    url: `workflow/task/getCompletedNodeInfo`,
    data: {
      pageNum: params.pageIndex,
      pageSize: params.pageSize,
      taskId: params.taskId
    }
  });
  if (resp.code === 0) {
    return resp.data;
  } else {
    return null;
  }
}
async function getUnHandledNodeInfo(params) {
  const resp = await import_util.iup.request.get({
    url: `workflow/task/getUnHandledNodeInfo`,
    data: {
      pageNum: params.pageIndex,
      pageSize: params.pageSize,
      taskId: params.taskId
    }
  });
  if (resp.code === 0) {
    return resp.data;
  } else {
    return null;
  }
}
async function getSignatureByUser() {
  const res = await import_util.iup.request.get({
    url: "/workflow/signature/getSignatureByUser"
  });
  if (res.code === 0) {
    return res.data;
  } else {
    return void 0;
  }
}
async function getNextUserTaskNodes(taskId) {
  const res = await import_util.iup.request.get({
    url: `/workflow/task/getNextUserTaskNodes?taskId=${taskId}`
  });
  if (res.code === 0) {
    return res.data;
  } else {
    return void 0;
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  RollBack,
  addSubTaskAsync,
  carbonCopy,
  checkPreCompleteTask,
  checkPreRollback,
  checkPreStartProcessInstance,
  compeleteTask,
  createOrUpdateContent,
  deleteContentById,
  getCommonWordHelp,
  getCompletedNodeInfo,
  getNextUserTaskNodes,
  getProcessInitialActivity,
  getRollBackInfo,
  getSignatureByUser,
  getSignatureListByCurrentUser,
  getToDoInfo,
  getUnHandledNodeInfo,
  getWorkFlowHis,
  getWorkFlowInfo,
  saveRemarkPanelWidth,
  updateNotificationReadFlg,
  validSignatureInfoByPassword
});
